﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BaseData.Exts;
using BaseLib.Helper;

namespace BaseData.HelperBootStrap
{
    public class TreeNodeData
    {
        public string Get()
        {
            using (var ctx = new ContextExt())
            {
                var items = ctx.Web_Base_News_Node.Where(w => (w.ParentId ?? 0) == 0).Select(s => new TreeNodeItem
                {
                    id = s.PkId,
                    parentid = s.ParentId ?? 0,
                    text = s.Title,
                    type = "folder",
                });
                return items.ObjectToJson();
            }
        }

        public class TreeNodeItem
        {
            public int id { get; set; }
            public int parentid { get; set; }
            public string text { get; set; }
            public string type { get; set; }
        }
    }
}
